var Stone = require('Stone');
var judger = require('FiveStoneJudger');

/**
 * 五子棋的主控制类
 */
export default class FiveStone {

    /**
     * 初始化棋盘
     * @param   page                    当前页面页面
     * @param   chessBoardSize          当前棋盘每行和列最多能下多少个子子
     * @param   chessboardSizePercent   棋盘的宽度相当于屏幕宽度的百分比(0<x<1)
     */
    constructor(chessBoardSize, chessboardSizePercent) {
        var self = this;
        var chessBoard = [];
        //占位
        var chessBoardCell = [];
        this.chessBoardSize = chessBoardSize;
        for (var r = 0; r < chessBoardSize; r++) {
            var row = [];
            var cellRow = [];
            for (var c = 0; c < chessBoardSize; c++) {
                row.push({
                    stoneType:Stone.none,
                    //位置使用到的时候才计算
                    pos:null
                });
                if (c < chessBoardSize - 1) {
                    cellRow.push(0);
                }
            }
            chessBoard.push(row);
            if (r < chessBoardSize - 1) {
                chessBoardCell.push(cellRow);
            }
        }
        this.chessBoard = chessBoard;
        this.chessBoardCell = chessBoardCell;
        //获取系统信息
        wx.getSystemInfo({
            success: function(res) {
                self.chessboardSizePX = res.windowWidth * chessboardSizePercent;
                console.log('%c棋盘大小:%c' +
                 self.chessboardSizePX +
                  '%cpx',
                  'color:red;',
                  'color:blue;',
                  'color:black;'
                  );
                self.cellSizePX = self.chessboardSizePX / (chessBoardSize - 1);
                console.log('%c单元格大小:%c' +
                 self.cellSizePX +
                  '%cpx',
                  'color:red;',
                  'color:blue;',
                  'color:black;'
                  );
                  self.halfCellSizePX = self.cellSizePX * 0.5;
            }
        });
        this.Cnt=0;
        //当前下子的类型
        this.stone = Stone.black;
        //下子监听的回调集合
        this.onStepStoneCallbacks = [];
        //是否能够下子的开关
        this._canStep = true;
        //历史
        this.history = [];
        //设置裁判
        this.setJudger(judger);
    }

    /**
     * 通过事件获取下子在棋盘的位置
     */
    getStepLocation(e) {
        var curTarget = e.currentTarget;
        var offset = {
            x: curTarget.offsetLeft,
            y: curTarget.offsetTop
        };
        var touch = e.touches[0];
        //相对棋盘的位置
        var clientPos = {
            x:touch.pageX - offset.x,
            y:touch.pageY - offset.y
        };
        var stepPos = {
            x: Math.ceil((clientPos.x - this.halfCellSizePX) / this.cellSizePX),
            y: Math.ceil((clientPos.y - this.halfCellSizePX) / this.cellSizePX)
        };
        if (stepPos.x < 0 || stepPos.x >= this.chessBoardSize ||
            stepPos.y < 0 || stepPos.y >= this.chessBoardSize) {
                return null;
            }
        return stepPos;
    }

    /**
     * 通过事件获取下子在棋盘的绝对位置
     */
    getStepPosition(e) {
        var curTarget = e.currentTarget;
        var stepPos = this.getStepLocation(e);
        if (stepPos == null) {
            return null;
        }
        console.log(stepPos);
        var absPos = stepPos.clone();
        //后面的那个1像素怎么出来的我也不知道，反正减了之后位置看起来正很多
        absPos.x = absPos.x * this.cellSizePX + curTarget.offsetLeft - this.halfCellSizePX - 1;
        absPos.y = absPos.y * this.cellSizePX + curTarget.offsetTop - this.halfCellSizePX - 1;
        this.chessBoard[stepPos.x][stepPos.y].pos = absPos.clone();
        return absPos;
    }
    AIgetStepLocation() {
        var SCORE1=200000 //机器四子型
        var SCORE2=150000 //玩家四子型
        var SCORE3=10000 //机器三子_ooo_
        var SCORE4=5000 //玩家三子_ooo_
        var SCORE5=2400 //机器三子_ooox或xooo_
        var SCORE6=2300//玩家三子_ooox或xooo_
        var SCORE7=1250 //机器两子_oo_
        var SCORE8=1000 //玩家两子_oo_
        var SCORE9=400 //机器两子_oox或xoo_
        var SCORE10=380 //玩家两子_oox或xoo_
        var SCORE11=210 //机器一子_o_
        var SCORE12=120 //玩家一子_o_
        var SCORE13=60 //机器一子_ox或xo_
        var SCORE14=50 //玩家一子_ox或xo_
        var SCORE15=1210 //机器两子_o_o_(两边)
        var SCORE16=1110 //玩家两子_o_o_(两边)
        var SCORE17=1220//机器两子_o_o_(中间)
        var SCORE18=1100//玩家两子_o_o_(中间)
        var score=[]; //判断状态分值以此分析落子位置
        var ROW=this.chessBoardSize;
        var LINE=this.chessBoardSize;
        var i, j,row=1,line=1,max;
        var coordinate=[];
        for (i = 0; i < this.chessBoardSize; i++)
        {
            score[i]=[];
            coordinate[i]=[];
            for (j = 0; j < this.chessBoardSize; j++)
            {
                coordinate[i][j]=this.chessBoard[i][j].stoneType;
                score[i][j] = 0; //每个位置初始分值均为0
            }
        }
        for (i = 0; i < ROW; i++) //根据坐标周围的棋子计算得分
        {
            for (j = 0; j < LINE; j++)
            {
                if (coordinate[i][j] == 0 && //横向机器四子
                    ((i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 2) && //横向无间隔
                        (i + 4 < ROW && coordinate[i + 4][j] == 2) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 2) && //横向空一格
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向空两格
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向反空一格
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 2) && //横向反无间隔
                        (i - 4 >= 0 && coordinate[i - 4][j] == 2)))
                    score[i][j] += SCORE1;
                if (coordinate[i][j] == 0 && //纵向机器四子
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 2) && //纵向无间隔
                        (j + 4 < LINE && coordinate[i][j + 4] == 2) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 2) && //纵向空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向空两格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向反空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) ||
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 2) && //纵向反无间隔
                        (j - 4 >= 0 && coordinate[i][j - 4] == 2)))
                    score[i][j] += SCORE1;
                if (coordinate[i][j] == 0 && //右斜向机器四子
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 2) && //右斜向无间隔
                        (i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 2) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 2) && //右斜向空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向空两格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向反空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) ||
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 2) && //右斜向反无间隔
                        (i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 2)))
                    score[i][j] += SCORE1+20;
                if (coordinate[i][j] == 0 && //左斜向机器四子
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 2) && //左斜向无间隔
                        (i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 2) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 2) && //左斜向空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向空两格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向反空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) ||
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 2) && //左斜向反无间隔
                        (i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 2)))
                    score[i][j] += SCORE1+20;
                if (coordinate[i][j] == 0 && //横向玩家四子
                    ((i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 1) && //横向无间隔
                        (i + 4 < ROW && coordinate[i + 4][j] == 1) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 1) && //横向空一格
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向空两格
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向反空一格
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 1) && //横向反无间隔
                        (i - 4 >= 0 && coordinate[i - 4][j] == 1)))
                    score[i][j] += SCORE2;
                if (coordinate[i][j] == 0 && //纵向玩家四子
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 1) && //纵向无间隔
                        (j + 4 < LINE && coordinate[i][j + 4] == 1) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 1) && //纵向空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向空两格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向反空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) ||
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 1) && //纵向反无间隔
                        (j - 4 >= 0 && coordinate[i][j - 4] == 1)))
                    score[i][j] += SCORE2;
                if (coordinate[i][j] == 0 && //右斜向玩家四子
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 1) && //右斜向无间隔
                        (i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 1) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 1) && //右斜向空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向空两格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向反空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) ||
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 1) && //右斜向反无间隔
                        (i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 1)))
                    score[i][j] += SCORE2+10;
                if (coordinate[i][j] == 0 && //左斜向玩家四子
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 1) && //左斜向无间隔
                        (i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 1) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 1) && //左斜向空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向空两格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向反空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) ||
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 1) && //左斜向反无间隔
                        (i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 1)))
                    score[i][j] += SCORE2+10;
                if (coordinate[i][j] == 0 && //横向机器三子且无挡
                    ((i - 1 >= 0 && coordinate[i - 1][j] == 0) &&
                    (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 2) && //横向无间隔
                        (i + 4 < ROW && coordinate[i + 4][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 0) && //横向空一格
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 0) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向空两格
                        (i - 3 >= 0 && coordinate[i - 3][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 0) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向反无间隔
                        (i - 4 >= 0 && coordinate[i - 4][j] == 0)))
                    score[i][j] += SCORE3;
                if (coordinate[i][j] == 0 && //纵向机器三子且无挡
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 2) && //纵向无间隔
                        (j + 4 < LINE && coordinate[i][j + 4] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 0) && //纵向空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 0) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向空两格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 0) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向反空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 4 >= 0 && coordinate[i][j - 4] == 0)))
                    score[i][j] += SCORE3;
                if (coordinate[i][j] == 0 && //右斜向机器三子且无挡
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 2) && //右斜向无间隔
                        (i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 0) && //右斜向空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向空两格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向反无间隔
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 0)))
                    score[i][j] += SCORE3+20;
                if (coordinate[i][j] == 0 && //左斜向机器三子且无挡
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 2) && //左斜向无间隔
                        (i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 0) && //左斜向空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向空两格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向反无间隔
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 0)))
                    score[i][j] += SCORE3+20;
                if (coordinate[i][j] == 0 && //横向玩家三子且无挡
                    ((i - 1 >= 0 && coordinate[i - 1][j] == 0) &&
                    (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 1) && //横向无间隔
                        (i + 4 < ROW && coordinate[i + 4][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 0) && //横向空一格
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 0) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向空两格
                        (i - 3 >= 0 && coordinate[i - 3][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 0) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向反无间隔
                        (i - 4 >= 0 && coordinate[i - 4][j] == 0)))
                    score[i][j] += SCORE4;
                if (coordinate[i][j] == 0 && //纵向玩家三子且无挡
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 1) && //纵向无间隔
                        (j + 4 < LINE && coordinate[i][j + 4] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 0) && //纵向空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 0) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向空两格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 0) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向反空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 4 >= 0 && coordinate[i][j - 4] == 0)))
                    score[i][j] += SCORE4;
                if (coordinate[i][j] == 0 && //右斜向玩家三子且无挡
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 1) && //右斜向无间隔
                        (i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 0) && //右斜向空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向空两格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向反无间隔
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 0)))
                    score[i][j] += SCORE4+10;
                if (coordinate[i][j] == 0 && //左斜向玩家三子且无挡
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 1) && //左斜向无间隔
                        (i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 0) && //左斜向空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向空两格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向反无间隔
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 0)))
                    score[i][j] += SCORE4+10;
                if (coordinate[i][j] == 0 && //横向机器三子且有挡(顺向)
                    ((i - 1 >= 0 && coordinate[i - 1][j] == 0) &&
                    (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 2) && //横向无间隔
                        (i + 4 >= ROW || i + 4 < ROW && coordinate[i + 4][j] == 1) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 >= ROW || i + 3 < ROW && coordinate[i + 3][j] == 1) && //横向空一格
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 >= ROW || i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向空两格
                        (i - 3 >= 0 && coordinate[i - 3][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 >= ROW || i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向反无间隔
                        (i - 4 >= 0 && coordinate[i - 4][j] == 0)))
                    score[i][j] += SCORE5;
                if (coordinate[i][j] == 0 && //纵向机器三子且有挡(顺向)
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 2) && //纵向无间隔
                        (j + 4 >= LINE || j + 4 < LINE && coordinate[i][j + 4] == 1) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 >= LINE || j + 3 < LINE && coordinate[i][j + 3] == 1) && //纵向空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 >= LINE || j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向空两格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 0) ||
                        (j + 1 >= LINE || j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向反空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 4 >= 0 && coordinate[i][j - 4] == 0)))
                    score[i][j] += SCORE5;
                if (coordinate[i][j] == 0 && //右斜向机器三子且有挡(顺向)
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 2) && //右斜向无间隔
                        (i + 4 >= ROW || j + 4 >= LINE || i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 1) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 >= ROW || j + 3 >= LINE || i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 1) && //右斜向空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 >= ROW || j + 2 >= LINE || i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向空两格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 0) ||
                        (i + 1 >= ROW || j + 1 >= LINE || i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向反无间隔
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 0)))
                    score[i][j] += SCORE5+20;
                if (coordinate[i][j] == 0 && //左斜向机器三子且有挡(顺向)
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 2) && //左斜向无间隔
                        (i - 4 < 0 || j + 4 >= LINE || i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 1) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 < 0 || j + 3 >= LINE || i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 1) && //左斜向空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 < 0 || j + 2 >= LINE || i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向空两格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 0) ||
                        (i - 1 < 0 || j + 1 >= LINE || i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向反无间隔
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 0)))
                    score[i][j] += SCORE5+20;
                if (coordinate[i][j] == 0 && //横向玩家三子且有挡(顺向)
                    ((i - 1 >= 0 && coordinate[i - 1][j] == 0) &&
                    (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 1) && //横向无间隔
                        (i + 4 >= ROW || i + 4 < ROW && coordinate[i + 4][j] == 2) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 >= ROW || i + 3 < ROW && coordinate[i + 3][j] == 2) && //横向空一格
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 >= ROW || i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向空两格
                        (i - 3 >= 0 && coordinate[i - 3][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 >= ROW || i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向反无间隔
                        (i - 4 >= 0 && coordinate[i - 4][j] == 0)))
                    score[i][j] += SCORE6;
                if (coordinate[i][j] == 0 && //纵向玩家三子且有挡(顺向)
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 1) && //纵向无间隔
                        (j + 4 >= LINE || j + 4 < LINE && coordinate[i][j + 4] == 2) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 >= LINE || j + 3 < LINE && coordinate[i][j + 3] == 2) && //纵向空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 >= LINE || j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向空两格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 0) ||
                        (j + 1 >= LINE || j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向反空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 4 >= 0 && coordinate[i][j - 4] == 0)))
                    score[i][j] += SCORE6;
                if (coordinate[i][j] == 0 && //右斜向玩家三子且有挡(顺向)
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 1) && //右斜向无间隔
                        (i + 4 >= ROW || j + 4 >= LINE || i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 2) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 >= ROW || j + 3 >= LINE || i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 2) && //右斜向空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 >= ROW || j + 2 >= LINE || i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向空两格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 0) ||
                        (i + 1 >= ROW || j + 1 >= LINE || i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向反无间隔
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 0)))
                    score[i][j] += SCORE6+10;
                if (coordinate[i][j] == 0 && //左斜向玩家三子且有挡(顺向)
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 1) && //左斜向无间隔
                        (i - 4 < 0 || j + 4 >= LINE || i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 2) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 < 0 || j + 3 >= LINE || i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 2) && //左斜向空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 < 0 || j + 2 >= LINE || i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向空两格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 0) ||
                        (i - 1 < 0 || j + 1 >= LINE || i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向反无间隔
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 0)))
                    score[i][j] += SCORE6+10;
                if (coordinate[i][j] == 0 && //横向机器三子且有挡(反向)
                    ((i - 1 < 0 || i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                    (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 2) && //横向无间隔
                        (i + 4 < ROW && coordinate[i + 4][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 0) && //横向空一格
                        (i - 2 < 0 || i - 2 >= 0 && coordinate[i - 2][j] == 1) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 0) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向空两格
                        (i - 3 < 0 || i - 3 >= 0 && coordinate[i - 3][j] == 1) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 0) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向反无间隔
                        (i - 4 < 0 || i - 4 >= 0 && coordinate[i - 4][j] == 1)))
                    score[i][j] += SCORE5;
                if (coordinate[i][j] == 0 && //纵向机器三子且有挡(反向)
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 2) && //纵向无间隔
                        (j + 4 < LINE && coordinate[i][j + 4] == 0) &&
                        (j - 1 < 0 || j - 1 >= 0 && coordinate[i][j - 1] == 1) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 0) && //纵向空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 2 < 0 || j - 2 >= 0 && coordinate[i][j - 2] == 1) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 0) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向空两格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 3 < 0 || j - 3 >= 0 && coordinate[i][j - 3] == 1) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 0) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向反空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 4 < 0 || j - 4 >= 0 && coordinate[i][j - 4] == 1)))
                    score[i][j] += SCORE5;
                if (coordinate[i][j] == 0 && //右斜向机器三子且有挡(反向)
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 2) && //右斜向无间隔
                        (i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 0) &&
                        (i - 1 < 0 || j - 1 < 0 || i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 0) && //右斜向空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 2 < 0 || j - 2 < 0 || i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向空两格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 3 < 0 || j - 3 < 0 || i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 1) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向反无间隔
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 4 < 0 || j - 4 < 0 || i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 1)))
                    score[i][j] += SCORE5+20;
                if (coordinate[i][j] == 0 && //左斜向机器三子且有挡(反向)
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 2) && //左斜向无间隔
                        (i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 0) &&
                        (i + 1 >= ROW || j - 1 < 0 || i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 0) && //左斜向空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 2 >= ROW || j - 2 < 0 || i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向空两格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 3 >= ROW || j - 3 < 0 || i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 1) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向反无间隔
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 4 >= ROW || j - 4 < 4 || i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 1)))
                    score[i][j] += SCORE5+20;
                if (coordinate[i][j] == 0 && //横向玩家三子且有挡(反向)
                    ((i - 1 < 0 || i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                    (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 1) && //横向无间隔
                        (i + 4 < ROW && coordinate[i + 4][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 0) && //横向空一格
                        (i - 2 < 0 || i - 2 >= 0 && coordinate[i - 2][j] == 2) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 0) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向空两格
                        (i - 3 < 0 || i - 3 >= 0 && coordinate[i - 3][j] == 2) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i + 1 < ROW && coordinate[i + 1][j] == 0) &&
                        (i - 3 >= 0 && coordinate[i - 3][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向反无间隔
                        (i - 4 < 0 || i - 4 >= 0 && coordinate[i - 4][j] == 2)))
                    score[i][j] += SCORE6;
                if (coordinate[i][j] == 0 && //纵向玩家三子且有挡(反向)
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 1) && //纵向无间隔
                        (j + 4 < LINE && coordinate[i][j + 4] == 0) &&
                        (j - 1 < 0 || j - 1 >= 0 && coordinate[i][j - 1] == 2) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 0) && //纵向空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 2 < 0 || j - 2 >= 0 && coordinate[i][j - 2] == 2) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 0) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向空两格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 3 < 0 || j - 3 >= 0 && coordinate[i][j - 3] == 2) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 0) &&
                        (j - 3 >= 0 && coordinate[i][j - 3] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向反空一格
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 4 < 0 || j - 4 >= 0 && coordinate[i][j - 4] == 2)))
                    score[i][j] += SCORE6;
                if (coordinate[i][j] == 0 && //右斜向玩家三子且有挡(反向)
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 1) && //右斜向无间隔
                        (i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 0) &&
                        (i - 1 < 0 || j - 1 < 0 || i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 0) && //右斜向空一格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 2 < 0 || j - 2 < 0 || i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向空两格
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 3 < 0 || j - 3 < 0 || i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 2) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0) &&
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向反无间隔
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 4 < 0 || j - 4 < 0 || i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 2)))
                    score[i][j] += SCORE6+10;
                if (coordinate[i][j] == 0 && //左斜向玩家三子且有挡(反向)
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 1) && //左斜向无间隔
                        (i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 0) &&
                        (i + 1 >= ROW || j - 1 < 0 || i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 0) && //左斜向空一格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 2 >= ROW || j - 2 < 0 || i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向空两格
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 3 >= ROW || j - 3 < 0 || i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 2) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0) &&
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向反无间隔
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 4 >= ROW || j - 4 < 4 || i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 2)))
                    score[i][j] += SCORE6+10;
                if (coordinate[i][j] == 0 && //机器两子无挡
                    ((i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 0) && //横向无间隔且无挡
                        (i - 1 >= 0 && coordinate[i - 1][j] == 0) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 0) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) && //横向空一格且无挡
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 0) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向反无间隔且无挡
                        (i - 3 >= 0 && coordinate[i - 3][j] == 0)))
                    score[i][j] += SCORE7;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 0) && //纵向无间隔且无挡
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) && //纵向空一格且无挡
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向反无间隔且无挡
                        (j - 3 >= 0 && coordinate[i][j - 3] == 0)))
                    score[i][j] += SCORE7;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 0) && //右斜向无间隔且无挡
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) && //右斜向空一格且无挡
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向反无间隔且无挡
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 0)))
                        score[i][j] += SCORE7+20;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 0) && //左斜向无间隔且无挡
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) && //左斜向空一格且无挡
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向反无间隔且无挡
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 0)))
                    score[i][j] += SCORE7+20;
                if (coordinate[i][j] == 0 && //玩家两子无挡
                    ((i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 0) && //横向无间隔且无挡
                        (i - 1 >= 0 && coordinate[i - 1][j] == 0) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 0) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) && //横向空一格且无挡
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 0) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向反无间隔且无挡
                        (i - 3 >= 0 && coordinate[i - 3][j] == 0)))
                    score[i][j] += SCORE8;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 0) && //纵向无间隔且无挡
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) && //纵向空一格且无挡
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向反无间隔且无挡
                        (j - 3 >= 0 && coordinate[i][j - 3] == 0)))
                    score[i][j] += SCORE8;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 0) && //右斜向无间隔且无挡
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) && //右斜向空一格且无挡
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向反无间隔且无挡
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 0)))
                    score[i][j] += SCORE8+10;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 0) && //左斜向无间隔且无挡
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) && //左斜向空一格且无挡
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向反无间隔且无挡
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 0)))
                    score[i][j] += SCORE8+10;
                if (coordinate[i][j] == 0 && //机器两子有挡(顺向)
                    ((i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 >= ROW || i + 3 < ROW && coordinate[i + 3][j] == 1) && //横向无间隔且有挡(顺向)
                        (i - 1 >= 0 && coordinate[i - 1][j] == 0) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 >= ROW || i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) && //横向空一格且有挡(顺向)
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) ||
                        (i + 1 >= ROW || i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向反无间隔且有挡(顺向)
                        (i - 3 >= 0 && coordinate[i - 3][j] == 0)))
                    score[i][j] += SCORE9;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 >= LINE || j + 3 < LINE && coordinate[i][j + 3] == 1) && //纵向无间隔且有挡(顺向)
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 >= LINE || j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) && //纵向空一格且有挡(顺向)
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) ||
                        (j + 1 >= LINE || j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向反无间隔且有挡(顺向)
                        (j - 3 >= 0 && coordinate[i][j - 3] == 0)))
                    score[i][j] += SCORE9;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 >= ROW || j + 3 >= LINE || i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 1) && //右斜向无间隔且有挡(顺向)
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 >= ROW || j + 2 >= LINE || i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) && //右斜向空一格且有挡(顺向)
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) ||
                        (i + 1 >= ROW || j + 1 >= LINE || i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向反无间隔且有挡(顺向)
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 0)))
                    score[i][j] += SCORE9+20;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 < 0 || j + 3 >= LINE || i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 1) && //左斜向无间隔且有挡(顺向)
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 < 0 || j + 2 >= LINE || i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) && //左斜向空一格且有挡(顺向)
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) ||
                        (i - 1 < 0 || j + 1 >= LINE || i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向反无间隔且有挡(顺向)
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 0)))
                    score[i][j] += SCORE9+20;
                if (coordinate[i][j] == 0 && //玩家两子有挡(顺向)
                    ((i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 >= ROW || i + 3 < ROW && coordinate[i + 3][j] == 2) && //横向无间隔且有挡(顺向)
                        (i - 1 >= 0 && coordinate[i - 1][j] == 0) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 >= ROW || i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) && //横向空一格且有挡(顺向)
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) ||
                        (i + 1 >= ROW || i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向反无间隔且有挡(顺向)
                        (i - 3 >= 0 && coordinate[i - 3][j] == 0)))
                    score[i][j] += SCORE10;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 >= LINE || j + 3 < LINE && coordinate[i][j + 3] == 2) && //纵向无间隔且有挡(顺向)
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 >= LINE || j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) && //纵向空一格且有挡(顺向)
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) ||
                        (j + 1 >= LINE || j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向反无间隔且有挡(顺向)
                        (j - 3 >= 0 && coordinate[i][j - 3] == 0)))
                    score[i][j] += SCORE10;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 >= ROW || j + 3 >= LINE || i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 2) && //右斜向无间隔且有挡(顺向)
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 >= ROW || j + 2 >= LINE || i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) && //右斜向空一格且有挡(顺向)
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) ||
                        (i + 1 >= ROW || j + 1 >= LINE || i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向反无间隔且有挡(顺向)
                        (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 0)))
                    score[i][j] += SCORE10+10;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 < 0 || j + 3 >= LINE || i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 2) && //左斜向无间隔且有挡(顺向)
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 < 0 || j + 2 >= LINE || i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) && //左斜向空一格且有挡(顺向)
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) ||
                        (i - 1 < 0 || j + 1 >= LINE || i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向反无间隔且有挡(顺向)
                        (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 0)))
                    score[i][j] += SCORE10+10;
                if (coordinate[i][j] == 0 && //机器两子有挡(反向)
                    ((i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 0) && //横向无间隔且有挡(反向)
                        (i - 1 < 0 || i - 1 >= 0 && coordinate[i - 1][j] == 1) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 0) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) && //横向空一格且有挡(反向)
                        (i - 2 < 0 || i - 2 >= 0 && coordinate[i - 2][j] == 1) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 0) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 2) && //横向反无间隔且有挡(反向)
                        (i - 3 < 0 || i - 3 >= 0 && coordinate[i - 3][j] == 1)))
                    score[i][j] += SCORE9;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 0) && //纵向无间隔且有挡(反向)
                        (j - 1 < 0 || j - 1 >= 0 && coordinate[i][j - 1] == 1) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) && //纵向空一格且有挡(反向)
                        (j - 2 < 0 || j - 2 >= 0 && coordinate[i][j - 2] == 1) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 2) && //纵向反无间隔且有挡(反向)
                        (j - 3 < 0 || j - 3 >= 0 && coordinate[i][j - 3] == 1)))
                    score[i][j] += SCORE9;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 0) && //右斜向无间隔且有挡(反向)
                        (i - 1 < 0 || j - 1 < 0 || i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) && //右斜向空一格且有挡(反向)
                        (i - 2 < 0 || j - 2 < 0 || i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) && //右斜向反无间隔且有挡(反向)
                        (i - 3 < 0 || j - 3 < 0 || i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 1)))
                    score[i][j] += SCORE9+20;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 0) && //左斜向无间隔且有挡(反向)
                        (i + 1 >= ROW || j - 1 < 0 || i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) && //左斜向空一格且有挡(反向)
                        (i + 2 >= ROW || j - 2 < 0 || i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) && //左斜向反无间隔且有挡(反向)
                        (i + 3 >= ROW || j - 3 < 0 || i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 1)))
                    score[i][j] += SCORE9+20;
                if (coordinate[i][j] == 0 && //玩家两子有挡(反向)
                    ((i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                        (i + 3 < ROW && coordinate[i + 3][j] == 0) && //横向无间隔且有挡(反向)
                        (i - 1 < 0 || i - 1 >= 0 && coordinate[i - 1][j] == 2) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                        (i + 2 < ROW && coordinate[i + 2][j] == 0) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) && //横向空一格且有挡(反向)
                        (i - 2 < 0 || i - 2 >= 0 && coordinate[i - 2][j] == 2) ||
                        (i + 1 < ROW && coordinate[i + 1][j] == 0) &&
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 1) && //横向反无间隔且有挡(反向)
                        (i - 3 < 0 || i - 3 >= 0 && coordinate[i - 3][j] == 2)))
                    score[i][j] += SCORE10;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                        (j + 3 < LINE && coordinate[i][j + 3] == 0) && //纵向无间隔且有挡(反向)
                        (j - 1 < 0 || j - 1 >= 0 && coordinate[i][j - 1] == 2) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                        (j + 2 < LINE && coordinate[i][j + 2] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) && //纵向空一格且有挡(反向)
                        (j - 2 < 0 || j - 2 >= 0 && coordinate[i][j - 2] == 2) ||
                        (j + 1 < LINE && coordinate[i][j + 1] == 0) &&
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 1) && //纵向反无间隔且有挡(反向)
                        (j - 3 < 0 || j - 3 >= 0 && coordinate[i][j - 3] == 2)))
                    score[i][j] += SCORE10;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                        (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 0) && //右斜向无间隔且有挡(反向)
                        (i - 1 < 0 || j - 1 < 0 || i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                        (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) && //右斜向空一格且有挡(反向)
                        (i - 2 < 0 || j - 2 < 0 || i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 2) ||
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0) &&
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 1) && //右斜向反无间隔且有挡(反向)
                        (i - 3 < 0 || j - 3 < 0 || i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 2)))
                    score[i][j] += SCORE10+10;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                        (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 0) && //左斜向无间隔且有挡(反向)
                        (i + 1 >= ROW || j - 1 < 0 || i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                        (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) && //左斜向空一格且有挡(反向)
                        (i + 2 >= ROW || j - 2 < 0 || i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 2) ||
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0) &&
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 1) && //左斜向反无间隔且有挡(反向)
                        (i + 3 >= ROW || j - 3 < 0 || i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 2)))
                    score[i][j] += SCORE10+10;
                if (coordinate[i][j] == 0 && //机器一子无挡
                    ((i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 0) && //横向无挡
                        (i - 1 >= 0 && coordinate[i - 1][j] == 0) ||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) && //横向反无挡
                        (i + 1 < ROW && coordinate[i + 1][j] == 0)))
                    score[i][j] += SCORE11;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 0) && //纵向无挡
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0) ||
                        (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) && //纵向反无挡
                        (j + 1 < LINE && coordinate[i][j + 1] == 0)))
                    score[i][j] += SCORE11;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) && //右斜向无挡
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0) ||
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) && //右斜向反无挡
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0)))
                    score[i][j] += SCORE11+20;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) && //左斜向无挡
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0) ||
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) && //左斜向反无挡
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0)))
                    score[i][j] += SCORE11+20;
                if (coordinate[i][j] == 0 && //玩家一子无挡
                    ((i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 0) && //横向无挡
                        (i - 1 >= 0 && coordinate[i - 1][j] == 0)||
                        (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                        (i - 2 >= 0 && coordinate[i - 2][j] == 0) && //横向反无挡
                        (i + 1 < ROW && coordinate[i + 1][j] == 0)))
                    score[i][j] += SCORE12+10;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 0) && //纵向无挡
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0)||
                        (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                        (j - 2 >= 0 && coordinate[i][j - 2] == 0) && //纵向反无挡
                        (j + 1 < LINE && coordinate[i][j + 1] == 0)))
                    score[i][j] += SCORE12+10;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) && //右斜向无挡
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0)||
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                        (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) && //右斜向反无挡
                        (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 0)))
                    score[i][j] += SCORE12;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) && //左斜向无挡
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0)||
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                        (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) && //左斜向反无挡
                        (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 0)))
                    score[i][j] += SCORE12;
                if (coordinate[i][j] == 0 && //机器一子有挡(顺向)
                    ((i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                    (i + 2 >= ROW || i + 2 < ROW && coordinate[i + 2][j] == 1) && //横向有挡(顺向)
                        (i - 1 >= 0 && coordinate[i - 1][j] == 0)))
                    score[i][j] += SCORE13;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 >= LINE || j + 2 < LINE && coordinate[i][j + 2] == 1) && //纵向有挡(顺向)
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0)))
                    score[i][j] += SCORE13;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 >= ROW || j + 2 >= LINE || i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) && //右斜向有挡(顺向)
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0)))
                    score[i][j] += SCORE13+20;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 < 0 || j + 2 >= LINE || i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) && //左斜向有挡(顺向)
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0)))
                    score[i][j] += SCORE13+20;
                if (coordinate[i][j] == 0 && //玩家一子有挡(顺向)
                    ((i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                    (i + 2 >= ROW || i + 2 < ROW && coordinate[i + 2][j] == 2) && //横向有挡(顺向)
                        (i - 1 >= 0 && coordinate[i - 1][j] == 0)))
                    score[i][j] += SCORE14;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 >= LINE || j + 2 < LINE && coordinate[i][j + 2] == 2) && //纵向有挡(顺向)
                        (j - 1 >= 0 && coordinate[i][j - 1] == 0)))
                    score[i][j] += SCORE14;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 >= ROW || j + 2 >= LINE || i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) && //右斜向有挡(顺向)
                        (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 0)))
                    score[i][j] += SCORE14+10;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 < 0 || j + 2 >= LINE || i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) && //左斜向有挡(顺向)
                        (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 0)))
                    score[i][j] += SCORE14+10;
                if (coordinate[i][j] == 0 && //机器一子有挡(反向)
                    ((i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 0) && //横向有挡(反向)
                        (i - 1 < 0 || i - 1 >= 0 && coordinate[i - 1][j] == 1)))
                    score[i][j] += SCORE13;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 0) && //纵向有挡(反向)
                        (j - 1 < 0 || j - 1 >= 0 && coordinate[i][j - 1] == 1)))
                    score[i][j] += SCORE13;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) && //右斜向有挡(反向)
                        (i - 1 < 0 || j - 1 < 0 || i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1)))
                    score[i][j] += SCORE13+20;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) && //左斜向有挡(反向)
                        (i + 1 >= ROW || j - 1 < 0 || i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1)))
                    score[i][j] += SCORE13+20;
                if (coordinate[i][j] == 0 && //玩家一子有挡(反向)
                    ((i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 0) && //横向有挡(反向)
                        (i - 1 < 0 || i - 1 >= 0 && coordinate[i - 1][j] == 2)))
                    score[i][j] += SCORE14;
                if (coordinate[i][j] == 0 &&
                    ((j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 0) && //纵向有挡(反向)
                        (j - 1 < 0 || j - 1 >= 0 && coordinate[i][j - 1] == 2)))
                    score[i][j] += SCORE14;
                if (coordinate[i][j] == 0 &&
                    ((i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 0) && //右斜向有挡(反向)
                        (i - 1 < 0 || j - 1 < 0 || i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2)))
                    score[i][j] += SCORE14+10;
                if (coordinate[i][j] == 0 &&
                    ((i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 0) && //左斜向有挡(反向)
                        (i + 1 >= ROW || j - 1 < 0 || i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2)))
                    score[i][j] += SCORE14+10;
                if (coordinate[i][j] == 0 && //机器两子间隔
                    (i + 1 < ROW&&coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW&&coordinate[i + 2][j] == 0) &&
                    (i + 3 < ROW&&coordinate[i + 3][j] == 2) && //横向间隔两子
                    (i + 4 < ROW&&coordinate[i + 4][j] == 0))
                    score[i][j] += SCORE15;
                if (coordinate[i][j] == 0 &&
                    (j + 1 < LINE&&coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE&&coordinate[i][j + 2] == 0) &&
                    (j + 3 < LINE&&coordinate[i][j + 3] == 2) && //纵向间隔两子
                    (j + 4 < LINE&&coordinate[i][j + 4] == 0))
                    score[i][j] += SCORE15;
                if (coordinate[i][j] == 0 &&
                    (i + 1 < ROW&&j + 1 < LINE&&coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW&&j + 2 < LINE&&coordinate[i + 2][j + 2] == 0) &&
                    (i + 3 < ROW&&j + 3 < LINE&&coordinate[i + 3][j + 3] == 2) && //右斜向间隔两子
                    (i + 4 < ROW&&j + 4 < LINE&&coordinate[i + 4][j + 4] == 0))
                    score[i][j] += SCORE15+20;
                if (coordinate[i][j] == 0 &&
                    (i - 1 >= 0 && j + 1 < LINE&&coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE&&coordinate[i - 2][j + 2] == 0) &&
                    (i - 3 >= 0 && j + 3 < LINE&&coordinate[i - 3][j + 3] == 2) && //左斜向间隔两子
                    (i - 4 >= 0 && j + 4 < LINE&&coordinate[i - 4][j + 4] == 0))
                    score[i][j] += SCORE15+20;
                if (coordinate[i][j] == 0 && //机器两子反向间隔
                    (i - 1 >= 0 && coordinate[i - 1][j] == 2) &&
                    (i - 2 >= 0 && coordinate[i - 2][j] == 0) &&
                    (i - 3 >= 0 && coordinate[i - 3][j] == 2) && //横向间隔两子
                    (i - 4 >= 0 && coordinate[i - 4][j] == 0))
                    score[i][j] += SCORE15;
                if (coordinate[i][j] == 0 &&
                    (j - 1 >= 0 && coordinate[i][j - 1] == 2) &&
                    (j - 2 >= 0 && coordinate[i][j - 2] == 0) &&
                    (j - 3 >= 0 && coordinate[i][j - 3] == 2) && //纵向间隔两子
                    (j - 4 >= 0 && coordinate[i][j - 4] == 0))
                    score[i][j] += SCORE15;
                if (coordinate[i][j] == 0 &&
                    (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) &&
                    (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) &&
                    (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 2) && //右斜向间隔两子
                    (i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 0))
                    score[i][j] += SCORE15+20;
                if (coordinate[i][j] == 0 &&
                    (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                    (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) &&
                    (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 2) && //左斜向间隔两子
                    (i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 0))
                    score[i][j] += SCORE15+20;
                if (coordinate[i][j] == 0 && //玩家两子间隔
                    (i + 1 < ROW&&coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW&&coordinate[i + 2][j] == 0) &&
                    (i + 3 < ROW&&coordinate[i + 3][j] == 1) && //横向间隔两子
                    (i + 4 < ROW&&coordinate[i + 4][j] == 0))
                    score[i][j] += SCORE16;
                if (coordinate[i][j] == 0 &&
                    (j + 1 < LINE&&coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE&&coordinate[i][j + 2] == 0) &&
                    (j + 3 < LINE&&coordinate[i][j + 3] == 1) && //纵向间隔两子
                    (j + 4 < LINE&&coordinate[i][j + 4] == 0))
                    score[i][j] += SCORE16;
                if (coordinate[i][j] == 0 &&
                    (i + 1 < ROW&&j + 1 < LINE&&coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW&&j + 2 < LINE&&coordinate[i + 2][j + 2] == 0) &&
                    (i + 3 < ROW&&j + 3 < LINE&&coordinate[i + 3][j + 3] == 1) && //右斜向间隔两子
                    (i + 4 < ROW&&j + 4 < LINE&&coordinate[i + 4][j + 4] == 0))
                    score[i][j] += SCORE16+10;
                if (coordinate[i][j] == 0 &&
                    (i - 1 >= 0 && j + 1 < LINE&&coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE&&coordinate[i - 2][j + 2] == 0) &&
                    (i - 3 >= 0 && j + 3 < LINE&&coordinate[i - 3][j + 3] == 1) && //左斜向间隔两子
                    (i - 4 >= 0 && j + 4 < LINE&&coordinate[i - 4][j + 4] == 0))
                    score[i][j] += SCORE16+10;
                if (coordinate[i][j] == 0 && //机器两子反向间隔
                    (i - 1 >= 0 && coordinate[i - 1][j] == 1) &&
                    (i - 2 >= 0 && coordinate[i - 2][j] == 0) &&
                    (i - 3 >= 0 && coordinate[i - 3][j] == 1) && //横向间隔两子
                    (i - 4 >= 0 && coordinate[i - 4][j] == 0))
                    score[i][j] += SCORE16;
                if (coordinate[i][j] == 0 &&
                    (j - 1 >= 0 && coordinate[i][j - 1] == 1) &&
                    (j - 2 >= 0 && coordinate[i][j - 2] == 0) &&
                    (j - 3 >= 0 && coordinate[i][j - 3] == 1) && //纵向间隔两子
                    (j - 4 >= 0 && coordinate[i][j - 4] == 0))
                    score[i][j] += SCORE16;
                if (coordinate[i][j] == 0 &&
                    (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) &&
                    (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0) &&
                    (i - 3 >= 0 && j - 3 >= 0 && coordinate[i - 3][j - 3] == 1) && //右斜向间隔两子
                    (i - 4 >= 0 && j - 4 >= 0 && coordinate[i - 4][j - 4] == 0))
                    score[i][j] += SCORE16+10;
                if (coordinate[i][j] == 0 &&
                    (i + 1 < ROW && j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                    (i + 2 < ROW && j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) &&
                    (i + 3 < ROW && j - 3 >= 0 && coordinate[i + 3][j - 3] == 1) && //左斜向间隔两子
                    (i + 4 < ROW && j - 4 >= 0 && coordinate[i + 4][j - 4] == 0))
                    score[i][j] += SCORE16+10;
                if (coordinate[i][j] == 0 && //机器两子两边
                    (i + 1 < ROW&&coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW&&coordinate[i + 2][j] == 0) &&
                    (i - 1 >= 0 && coordinate[i - 1][j] == 2) && //横向两边
                    (i - 2 >= 0 && coordinate[i - 2][j] == 0))
                    score[i][j] += SCORE17;
                if (coordinate[i][j] == 0 && //机器两子两边
                    (j + 1 < LINE&&coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE&&coordinate[i][j + 2] == 0) &&
                    (j - 1 >= 0 && coordinate[i][j - 1] == 2) && //纵向两边
                    (j - 2 >= 0 && coordinate[i][j - 2] == 0))
                    score[i][j] += SCORE17;
                if (coordinate[i][j] == 0 && //机器两子两边
                    (i + 1 < ROW&&j + 1 < LINE&&coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW&&j + 2 < LINE&&coordinate[i + 2][j + 2] == 0) &&
                    (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 2) && //右斜向两边
                    (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0))
                    score[i][j] += SCORE17+20;
                if (coordinate[i][j] == 0 && //机器两子两边
                    (i + 1 < ROW&&j - 1 >= 0 && coordinate[i + 1][j - 1] == 2) &&
                    (i + 2 < ROW&&j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) &&
                    (i - 1 >= 0 && j + 1 < LINE&&coordinate[i - 1][j + 1] == 2) && //左斜向两边
                    (i - 2 >= 0 && j + 2 < LINE&&coordinate[i - 2][j + 2] == 0))
                    score[i][j] += SCORE17+20;
                if (coordinate[i][j] == 0 && //玩家两子两边
                    (i + 1 < ROW&&coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW&&coordinate[i + 2][j] == 0) &&
                    (i - 1 >= 0 && coordinate[i - 1][j] == 1) && //横向两边
                    (i - 2 >= 0 && coordinate[i - 2][j] == 0))
                    score[i][j] += SCORE18;
                if (coordinate[i][j] == 0 && //玩家两子两边
                    (j + 1 < LINE&&coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE&&coordinate[i][j + 2] == 0) &&
                    (j - 1 >= 0 && coordinate[i][j - 1] == 1) && //纵向两边
                    (j - 2 >= 0 && coordinate[i][j - 2] == 0))
                    score[i][j] += SCORE18;
                if (coordinate[i][j] == 0 && //玩家两子两边
                    (i + 1 < ROW&&j + 1 < LINE&&coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW&&j + 2 < LINE&&coordinate[i + 2][j + 2] == 0) &&
                    (i - 1 >= 0 && j - 1 >= 0 && coordinate[i - 1][j - 1] == 1) && //右斜向两边
                    (i - 2 >= 0 && j - 2 >= 0 && coordinate[i - 2][j - 2] == 0))
                    score[i][j] += SCORE18+10;
                if (coordinate[i][j] == 0 && //玩家两子两边
                    (i + 1 < ROW&&j - 1 >= 0 && coordinate[i + 1][j - 1] == 1) &&
                    (i + 2 < ROW&&j - 2 >= 0 && coordinate[i + 2][j - 2] == 0) &&
                    (i - 1 >= 0 && j + 1 < LINE&&coordinate[i - 1][j + 1] == 1) && //左斜向两边
                    (i - 2 >= 0 && j + 2 < LINE&&coordinate[i - 2][j + 2] == 0))
                    score[i][j] += SCORE18+10;
            }
        }
        max = score[ROW-1][LINE-1];
        row = ROW-1;
        line = LINE-1;
        if (coordinate[row][line] != 0)
        {
            for(i=0;i<ROW;i++)
                for(j=0;j<LINE;j++)
                    if (coordinate[i][j] == 0)
                    {
                        row = i;
                        line = j;
                        max = score[i][j];
                    }
        }
        for(i = 0; i < ROW; i++) //得出最高预测分及其坐标
            for (j = 0; j < LINE; j++)
                if (max < score[i][j])
                {
                    max = score[i][j];
                    row = i;
                    line = j;
                }
        this.step(row,line);
        var stepPos={x:row,y:line};
        return stepPos;
    }
    AIstep() {
        var stepPos = this.AIgetStepLocation();
        if (stepPos == null) {
            return null;
        }
        var absPos = stepPos.clone();
        //后面的那个1像素怎么出来的我也不知道，反正减了之后位置看起来正很多
        absPos.x = absPos.x * this.cellSizePX + this.halfCellSizePX*0.5;
        absPos.y = absPos.y * this.cellSizePX + this.halfCellSizePX*8.2;
        this.chessBoard[stepPos.x][stepPos.y].pos = absPos.clone();
        return absPos;
    }
    /**
     * 下棋，设置的是基于棋盘的坐标
     * @return  返回true就是下子成功，否则为失败
     */
    step(x, y) {
        if (this.canStepAt(x, y)) {
            this.Cnt=this.Cnt+1;
            this.chessBoard[x][y].stoneType = this.nowStone();
            const nowStone = this.nowStone();
            this.stone = nowStone == Stone.black ? Stone.white:Stone.black;
            this.onStepStone(nowStone, x, y);
            if (!(this.history instanceof Array)) {
                this.history = [];
            }
            //插入到历史
            this.history.push({
                'x':x,
                'y':y,
                'stoneType':nowStone
            });
            this.newjudger();
            this.judge(nowStone, x, y);
            return true;
        }
        return false;
    }
    getCnt(){
        return this.Cnt;
    }
    /**
     * 悔棋
     */
    undo() {
        if (!(this.history instanceof Array) || this.history.length <= 0) {
            return;
        }
        const lastStoneIndex = this.history.length - 1;
        const lastStone = this.history[lastStoneIndex];
        this.stone = lastStone.stoneType;
        this.history.splice(lastStoneIndex, 1);
        this.chessBoard[lastStone.x][lastStone.y].stoneType = Stone.none;
        this.allowStep();
    }

    /**
     * 判断该棋子是否能够下
     */
    canStepAt(x, y) {
        if (x < 0 || x >= this.chessBoardSize ||
            y < 0 || y >= this.chessBoardSize ||
            this.chessBoard[x][y].stoneType != Stone.none) {
                return false;
        }
        return this._canStep;
    }

    /**
     * 当触发了下子的事件的时候
     */
    onStepStone(nowStone, x, y) {
        if (this.onStepStoneCallbacks instanceof Array) {
            for (var i in this.onStepStoneCallbacks) {
                const cb = this.onStepStoneCallbacks[i];
                if (typeof(cb) === 'function') {
                    cb.call(this, nowStone, x, y);
                }
            }
        }
    }

    /**
     * 添加下子的监听器
     * @return 如果返回0则代表插入失败，成功返回索引
     */
    addOnStepStoneCallback(func) {
        if (!(this.onStepStoneCallbacks instanceof Array)) {
            this.onStepStoneCallbacks = [];
        }
        if (typeof(func) == 'function') {
            //push以后会返回数组的长度，所以减一之后就会是对应的索引
            return this.onStepStoneCallbacks.push(func) - 1;
        }
        return 0;
    }

    /**
     * 通过索引删除下子的监听器
     */
    removeOnStepStoneCallback(index) {
        if (this.onStepStoneCallbacks instanceof Array) {
            if (this.onStepStoneCallbacks.length > index) {
                this.onStepStoneCallbacks.splice(index, 1);
            }
        }
    }

    /**
     * 重新开局
     */
    restart() {
        this.stone = Stone.black;
        for (var r in this.chessBoard) {
            for (var c in this.chessBoard[r]) {
                this.chessBoard[r][c].stoneType = Stone.none;
            }
        }
        //清空历史
        this.history = [];
        this.allowStep();
        this.Cnt=0;
    }

    /**
     * 阻止下子
     */
    preventStep() {
        this._canStep = false;
    }

    /**
     * 允许下子
     */
    allowStep() {
        this._canStep = true;
    }

    /**
     * 获取当前是下的黑子还是白子
     */
    nowStone() {
        return this.stone;
    }

    /**
     * 返回当前是否允许下子
     */
    canStep() {
        return this._canStep;
    }

    /**
     * 进行裁判(下子成功之后触发)
     * @param stepStone 当前下子的类型
     * @param x         下子基于棋盘的x坐标
     * @param y         下子基于棋盘的y坐标
     */
    judge(stepStone, x, y) {
        if (typeof(this._judger) == 'function') {
            this._judger.call(this, stepStone, x, y, this._winCallback);
        }
    }

    /**
     * 设置裁判回调
     */
    setJudger(func) {
        if (typeof(func) == 'function') {
            this._judger = func;
        }
    }

    /**
     * 设置胜利之后的回调
     */
    setWinCallback(func) {
        if (typeof(func) == 'function') {
            this._winCallback = func;
        }
    }
    newjudger()
    {
        var i, j;
        var score = 0;
        var ROW=this.chessBoardSize;
        var LINE=this.chessBoardSize;
        var coordinate=[];
        for (i = 0; i < this.chessBoardSize; i++)
        {
            coordinate[i]=[];
            for (j = 0; j < this.chessBoardSize; j++)
            {
                coordinate[i][j]=this.chessBoard[i][j].stoneType;
            }
        }
        for (i = 0; i < ROW; i++)
        {
            for (j = 0; j < LINE; j++)
            {
                if (coordinate[i][j] == 2 && //横向机器五子获胜
                    (i + 1 < ROW && coordinate[i + 1][j] == 2) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 2) &&
                    (i + 3 < ROW && coordinate[i + 3][j] == 2) &&
                    (i + 4 < ROW && coordinate[i + 4][j] == 2) ||
                    coordinate[i][j] == 2 && //纵向机器五子获胜
                    (j + 1 < LINE && coordinate[i][j + 1] == 2) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 2) &&
                    (j + 3 < LINE && coordinate[i][j + 3] == 2) &&
                    (j + 4 < LINE && coordinate[i][j + 4] == 2) ||
                    coordinate[i][j] == 2 && //右斜向机器五子获胜
                    (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 2) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 2) &&
                    (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 2) &&
                    (i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 2) ||
                    coordinate[i][j] == 2 && //左斜向机器五子获胜
                    (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 2) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 2) &&
                    (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 2) &&
                    (i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 2) &&
                    score < 3)
                    {
                        score = 3;
                        wx.showToast({
                            title: "你输了！！",
                            duration: 4000
                          });
                        this.preventStep();
                    }
                else if (coordinate[i][j] == 1 && //横向玩家五子获胜
                    (i + 1 < ROW && coordinate[i + 1][j] == 1) &&
                    (i + 2 < ROW && coordinate[i + 2][j] == 1) &&
                    (i + 3 < ROW && coordinate[i + 3][j] == 1) &&
                    (i + 4 < ROW && coordinate[i + 4][j] == 1) ||
                    coordinate[i][j] == 1 && //纵向玩家五子获胜
                    (j + 1 < LINE && coordinate[i][j + 1] == 1) &&
                    (j + 2 < LINE && coordinate[i][j + 2] == 1) &&
                    (j + 3 < LINE && coordinate[i][j + 3] == 1) &&
                    (j + 4 < LINE && coordinate[i][j + 4] == 1) ||
                    coordinate[i][j] == 1 && //右斜向玩家五子获胜
                    (i + 1 < ROW && j + 1 < LINE && coordinate[i + 1][j + 1] == 1) &&
                    (i + 2 < ROW && j + 2 < LINE && coordinate[i + 2][j + 2] == 1) &&
                    (i + 3 < ROW && j + 3 < LINE && coordinate[i + 3][j + 3] == 1) &&
                    (i + 4 < ROW && j + 4 < LINE && coordinate[i + 4][j + 4] == 1) ||
                    coordinate[i][j] == 1 && //左斜向玩家五子获胜
                    (i - 1 >= 0 && j + 1 < LINE && coordinate[i - 1][j + 1] == 1) &&
                    (i - 2 >= 0 && j + 2 < LINE && coordinate[i - 2][j + 2] == 1) &&
                    (i - 3 >= 0 && j + 3 < LINE && coordinate[i - 3][j + 3] == 1) &&
                    (i - 4 >= 0 && j + 4 < LINE && coordinate[i - 4][j + 4] == 1) &&
                    score < 2)
                    {
                        score = 2;
                        wx.showToast({
                            title: "你赢了！！",
                            duration: 4000
                        });
                        this.preventStep();
                    }
            }
        }
        if (score == 0)
        {
            for (i = 0; i < ROW; i++) //棋盘落满，平局
            {
                for (j = 0; j < LINE; j++)
                    if (coordinate[i][j] == 0)
                        break;
                if (coordinate[i][j] == 0)
                    break;
            }
            if (i == ROW || j == LINE)
            {
                score = 1;
                wx.showToast({
                    title: "平局！！",
                    duration: 4000
                  });
            }
        }
        console.log(score);

        return score;
    }
}